/**
 * Alibaba.com.cn Inc.
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.starlink.common.scheduled;

import com.starlink.model.domain.OtherOrderDO;
import com.starlink.model.domain.SchoolbagOrderDO;
import com.starlink.service.OtherOrderService;
import com.starlink.service.SchoolbagOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author zhanghong
 * @version OtherOrderTask.java, v 0.1 2024/6/23 17:11 下午 OtherOrderTask Exp $$
 */
@Service
public class OtherOrderTask {
    @Autowired
    private OtherOrderService otherOrderService;

    /**
     * 订单支付超时取消
     */
    @Scheduled(cron = "0 */1 * * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void unPayOrderCancel() {
        otherOrderService.lambdaUpdate().eq(OtherOrderDO::getOrderStatus, 1).lt(OtherOrderDO::getTimeout, new Date()).remove();
    }
}
